// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Wrecking Ball Object
// Script Author: Christan Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 69 : TYPE_WRECKINGBALL


// Static Values

// Tables

event ObjectMain
	if object.state == 2
		object.rotation *= 248
		object.rotation >>= 8
		object.value0++
		temp0 = object.value0
		temp0 &= 7
		if temp0 == 4
			Rand(temp0, 32)
			temp0 -= 16
			temp0 <<= 16
			temp0 += object.xpos
			Rand(temp1, 32)
			temp1 -= 16
			temp1 <<= 16
			temp1 += object.ypos
			CreateTempObject(TypeName[Explosion], 0, temp0, temp1)
		end if
		if object.value0 == 180
			object.type = TypeName[Blank Object]
		end if
	end if
	foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
		if object.state == 1
			BoxCollisionTest(C_TOUCH, object.entityPos, -22, -22, 22, 22, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
			if checkResult == 1
				CallFunction(PlayerObject_Hit)
			end if
		end if
	next
end event


event ObjectDraw
	temp0 = object.rotation
	temp0 += 8
	temp0 >>= 4
	temp0 &= 7
	temp0++
	DrawSprite(temp0)
	object.inkEffect = INK_ADD
	object.alpha = 160
	DrawSpriteFX(0, FX_INK, object.xpos, object.ypos)
end event


event ObjectStartup
	LoadSpriteSheet("GHZ/Objects2.gif")
	SpriteFrame(-24, -24, 48, 48, 1, 77)
	SpriteFrame(-24, -24, 48, 48, 50, 77)
	SpriteFrame(-24, -24, 48, 48, 148, 126)
	SpriteFrame(-24, -24, 48, 48, 99, 126)
	SpriteFrame(-24, -24, 48, 48, 50, 126)
	SpriteFrame(-24, -24, 48, 48, 1, 126)
	SpriteFrame(-24, -24, 48, 48, 197, 77)
	SpriteFrame(-24, -24, 48, 48, 148, 77)
	SpriteFrame(-24, -24, 48, 48, 99, 77)
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
